Skip to main content

How to use JS SDK bridge token between Ethereum and Manta

Bridge ETH/ERC20 Between L1 and L2

Repo Link: bridge-between-l1-l2

Install

yarn

Setting Account

Prepare an account private key on L1 Sepolia and need some ETH

// open .env file
PRIVATE_KEY = YOUR_PRIVATE_KEY;

Choose Network

// mainnet
const networkConfig = config.mainnet;

// sepolia testnet
const networkConfig = config.sepoliaTestnet;

Bridge ETH from L1 to L2

await depositETH();

Bridge ERC20 Token from L1 to L2

// need to fill in the corresponding token address and decimals first
const erc20Token = {
l1Address: "",
l2Address: "",
decimals: 18,
};
await depositERC20();

Bridge ETH/ERC20 from L2 to L1

  1. Initiate Withdrawal
// withdraw ETH
const withdrawTxhash = await withdrawETH();

// withdraw ERC20 token
const withdrawTxhash = await withdrawERC20();
  1. Wait for 45 minutes
  2. Prove Withdrawal
await proveWithdrawMessage(withdrawTxhash);
  1. Wait for 3 days (Testnet: one minute)

  2. Claim Withdrawal

await finalizeWithdrawMessage(withdrawTxhash);

Bridge History

Withdraw Status

export enum WithdrawStatus {
WAIT_TO_PROVE = 1,
READY_TO_PROVE = 2,
IN_CHALLENGE_PERIOD = 3,
READY_FOR_RELAY = 4,
RELAYED = 5,
}